from django.db import models

# Create your models here.
class Blog(models.Model):
    user_id = models.IntegerField('拥有则id')
    title = models.CharField('标题',max_length=200)
    intro = models.CharField('简介',max_length=255)
    content = models.TextField('内容')
    create_time = models.DateField('创建时间',auto_created=True,auto_now=True)
    like = models.IntegerField('点赞数',default=0)
    is_del = models.BooleanField('是否逻辑删除',default=True)

    class Meta:
        db_table = 'blogs'

class Comment(models.Model):
    blog = models.ForeignKey('Blog',on_delete=models.CASCADE)
    user_id = models.IntegerField('评论者id')
    username = models.CharField('评论者',max_length=200,blank=True,null=True)
    content = models.CharField('评论内容',max_length=255)
    create_time = models.DateField('评论时间',auto_created=True,auto_now=True)
    class Meta:
        db_table = 'comment'

class Active(models.Model):
    user_id = models.IntegerField('用户')
    blog_id = models.IntegerField('博客id')
    is_active = models.BooleanField('是否点赞',default=True) # 默认True 可以点赞
    class Meta:
        db_table = 'active'
